package lzzy13;

import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;

public class TextSoportsMeet {
    public static void main(String[] args) {
        Student stu1 = new Student("01","张三","跑步");
        Student stu2 = new Student("02","李四","跑步，跳绳");
        Student stu3 = new Student("03","王五","跑步");
        Student stu4 = new Student("05","宗宗","跳绳");
        Student stu5 = new Student("052","六子","跳绳");
        Student stu6 = new Student("056","胖子","跳绳");
        Student stu7 = new Student("034","二狗","跑步");
        Student stu8 = new Student("59","铁蛋","跳绳，跑步");

        Student[] stuSun = {stu1,stu2,stu3,stu7,stu8};
        Set<Student> run = new HashSet<>(Arrays.asList(stuSun));
        Student[] stuTs = {stu2,stu4,stu5,stu6,stu8};
        Set<Student> rs = new HashSet<>(Arrays.asList(stuTs));

        Set<Student> rts = new HashSet<>();
        rts.addAll(run);
        rts.addAll(rs);
        System.out.print("报名参加运动会的人员：");
        for (Student s : rts){
            System.out.print(s.getName()+" ");
        }
        System.out.println();
        System.out.print("两项都参加的：");
        rts.retainAll(run);
        rts.retainAll(rs);
        for (Student s : rts){
            System.out.print(s.getName()+" ");
        }
        System.out.println();
        System.out.print("只参加跳绳没参加跑步的同学：");
        rts.addAll(rs);
        rts.removeAll(run);
        for (Student s : rts){
            System.out.print(s.getName()+" ");
        }
    }
}
